package cn.edu.hqu.cst.android.wzc.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private TextView tv1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv1 = findViewById(R.id.T1);
        Button bt1 = findViewById(R.id.B1);//ACTIVITY作为监听器
        Button bt2 = findViewById(R.id.B2);//内部类作为监听器
        Button bt3 = findViewById(R.id.B3);//匿名内部类作为监听器
        Button bt4 = findViewById(R.id.B4);//LAMBDA表达式作为监听器
        Button bt5 = findViewById(R.id.B5);//外部类作为监听器
        Button bt6 = findViewById(R.id.B6);//监听器绑定到标签
        Button bt7 = findViewById(R.id.B7);//显示系统信息
        Button bt8 = findViewById(R.id.B8);//显示进度条
        bt1.setOnClickListener(this);
        bt2.setOnClickListener(new MyClickListener());
        bt3.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick (View v)
            {
                tv1.setText("匿名内部类作为监听器");
            }
        });
        bt4.setOnClickListener(view -> tv1.setText("LAMBDA表达式作为监听器"));
        bt5.setOnClickListener(new ExteriorClick(tv1));
        bt7.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent =new Intent(MainActivity.this,ConfigurationTest.class);
                startActivity(intent);
            }
        });
        bt8.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent =new Intent(MainActivity.this,ProgressDialogTest.class);
                startActivity(intent);
            }
        });
    }
    @Override
        public void onClick (View v)
        {
            tv1.setText("ACTIVITY本身作为监听器类");
        }
        class MyClickListener implements View.OnClickListener
        {
            @Override
            public void onClick (View v)
            {
                tv1.setText("内部类作为监听器");
            }
        }
        public void lableclick(View source)
        {
            tv1.setText("监听器绑定到标签");
        }
}